/**
 * #### 或类型
 */
export type Or<C1 extends boolean, C2 extends boolean> = C1 extends true
  ? true
  : C2 extends true
  ? true
  : false;

/**
 * #### 且类型
 */
export type And<C1 extends boolean, C2 extends boolean> = C1 extends true
  ? C2 extends true
    ? true
    : false
  : false;

/**
 * #### 且类型3
 */
export type And3<
  C1 extends boolean,
  C2 extends boolean,
  C3 extends boolean
> = And<And<C1, C2>, C3>;

/**
 * #### 且类型4
 */
export type And4<
  C1 extends boolean,
  C2 extends boolean,
  C3 extends boolean,
  C4 extends boolean
> = And<And3<C1, C2, C3>, C4>;

/**
 * #### 非类型
 */
export type Not<C extends boolean> = C extends true ? false : true;

/**
 * #### 左侧是否是右侧的子类型
 */
export type CheckLeftIsExtendsRight<T extends any, R extends any> = T extends R
  ? true
  : false;

/**
 * #### 类型是否严格相等
 */
export type IsEqual<A, B> = (<T>() => T extends A ? 1 : 2) extends <
  T1
>() => T1 extends B ? 1 : 2
  ? true
  : false;

// 定义一个类型IfEquals，用于判断两个类型是否相等
export type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X
  ? 1
  : 2) extends <T>() => T extends Y ? 1 : 2
  ? A
  : B;

/**
 * #### 是否是any类型
 */
export type IsAny<T> = 0 extends 1 & T ? true : false;

/**
 * #### 类型差集
 */
export type Diff<T, C> = Exclude<T, C> | Exclude<C, T>;

/**
 * #### 类型并集
 */
export type SumAggregate<T, U> = T | U;

/**
 * #### 可空类型
 */
export type Nullable<T> = T | null | undefined;

/**
 * #### 非undefined或Null类型
 */
export type NonUndefined<T> = T extends undefined | null ? never : T;

type aaa = NonUndefined<null>;
/**
 * #### 是否是联合类型
 * @category Common
 * @example
 * ```ts
 * IsUnion<string | number> // true
 * IsUnion<string> // false
 * ```
 */
export type IsUnion<A, B = A> = A extends A
  ? [B] extends [A]
    ? false
    : true
  : never;

export type IsNever<T> = [T] extends [never] ? true : false;

/**
 * #### 原始类型的联合类型
 */
export type Primitive =
  | string
  | number
  | bigint
  | boolean
  | symbol
  | null
  | undefined;
